//牛客；最长回文子串
//要求：返回一个字符串中最长回文子串的长度
//https://www.nowcoder.com/questionTerminal/12e081cd10ee4794a2bd70c7d68f5507?orderByHotValue=1&questionTypes=000100&mutiTagIds=596&page=1&onlyReference=false
//思路：反转目标字符串后进行匹配
//

import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scanner=new Scanner(System.in);
		while(scanner.hasNext()){
			String str=scanner.next();
			System.out.println(getMaxLength(str));
		}
		scanner.close();
	}
	
	public static int getMaxLength(String str){
	String sb=new StringBuilder(str).reverse().toString();
	int len=sb.length();
	int[][] tmp=new int[len+1][len+1];
	int max=0;
	for(int i=1;i<len+1;i++){
		for(int j=1;j<len+1;j++){
			if(str.charAt(i-1)==sb.charAt(j-1)){
				tmp[i][j]=tmp[i-1][j-1]+1;
				}else{
				tmp[i][j]=0;
				}
			if(tmp[i][j]>max){
				max=tmp[i][j];
				}
			}
		}
	}
}